<%@ page import="com.party.core.model.system.TargetType" %>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="../include/tag.jsp"%>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>${signProject == null ? '发布' : '编辑'}跟进记录</title>
    <%@include file="../include/commonFile.jsp"%>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/ui/activity/publish_act.css">
    <style type="text/css">
        .place-text {
            width: 200px;
            float: left;
            margin-right: 10px;
        }
    </style>
</head><body>
<!--头部-->
<%@include file="../include/header.jsp"%>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp"%>
    <!--内容-->
    <section>
        <div class="section-main">

            <div class="add-form-content">
            <form id="myForm" class="layui-form mt20" method="post" action="${ctx}/records/records/save.do">
                <input type="hidden" name="id" value="${upRecords.id}" />
                <div class="layui-form-item">
                    <label class="layui-form-label">众筹者<span class="f-verify-red">*</span></label>
                    <div class="layui-input-block">
                        <input type="hidden" name="targetId" value="${upRecords.targetId}" />
                        <input type="text"   class="layui-input" value="${authorName}" readonly>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">图像</label>
                    <div class="cover-content">
                        <input type="hidden" name="pic" id="pic" lay-verify="pic" value="${upRecords.pic}" />
                        <c:if test="${upRecords == null || empty upRecords.pic}">
                            <span id="logo-img" class="cover-img" style="background-image:url(${ctx}/image/posterImg.png)"></span>
                        </c:if>
                        <c:if test="${upRecords != null && not empty upRecords.pic}">
                            <span id="logo-img" class="cover-img" style="background-image:url('${upRecords.pic}')"></span>
                        </c:if>
                        <a class="layui-btn layui-btn-danger" id="sel_pic_img">+添加图片</a>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">内容<span class="f-verify-red">*</span></label>
                    <div class="layui-input-block">
                        <textarea name="content" id="content" placeholder="内容" lay-verify="content" class="layui-textarea" >${upRecords.content}</textarea>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <a href="javascript:void(0)" class="layui-btn layui-btn-danger" lay-submit lay-filter="*">立即提交</a>
                        <a href="${ctx}/records/records/list.do?targetId=${upRecords.targetId}" class="layui-btn layui-btn-primary">取消</a>
                    </div>
                </div>
            </form>
            </div>
        </div>
        <!--底部-->
        <%@include file="../include/footer.jsp"%>
    </section>
</div>

<script>
    $(function() {
        layui.use([ 'form', 'laydate' ], function() {
            var form = layui.form, laydate = layui.laydate;


            //自定义验证规则
            form.verify({
                content : function (value) {
                    if (value == ""){
                        return '请填写跟进内容';
                    }
                }
            });

            //监听提交
            form.on('submit', function (data) {
                txz.submitObject(data.elem, function (callBack) {
                    var action = $("#myForm").attr("action");
                    $.post(action, $('#myForm').serialize(), function (res) {
                        typeof callBack === 'function' && callBack();
                        if (res.success) {
                            util.layerMsgSuccess("提交成功", function () {
                                location.href = "${ctx}/records/records/list.do?targetId=${upRecords.targetId}&activityId=${activityId}&eventId=${eventId}";
                            });
                        } else {
                            util.layerMsgError("提交失败")
                        }
                    });
                })
                return false;
            });
        });
        $('#sel_pic_img').click(function () {
            txz.openSelImg({
                min: 1,
                max: 1,
                info: '建议尺寸：800x450',
                type: '<%=TargetType.ZC_ACTIVITY.getCode()%>',
                cb: function (imgs) {
                    $('#logo-img').css('background-image', 'url(' + imgs[0].path + ')');
                    $('#pic').val(imgs[0].path);
                }
            })
        })
    })
</script>
<script type="text/javascript">
    txz.initHeader({
        nav:[{
            name: '众筹管理',
            href: '${ctx}/records/records/list.do?targetId=${upRecords.targetId}'
        },{
            name: '${empty upRecords.id ? '发布' : '编辑'}跟进记录',
            curr: true
        }],
        btns:[{
            name: '返回',
            href: 'javascript:history.back();',
            icon: 'back'
        }]
    });
</script>
</body>
</html>